<article class="" id="post-">
<header class="entry-header">
<h1 class="entry-title">.fadeOut()</h1>
<div class="entry-meta">
						所属分类：<span class="category"><a href="/category/effects/">特效</a> &gt; <a href="/category/effects/fading/">渐变</a></span>
<span class="pull-right">英文文档：<a href="https://api.jquery123.com/fadeOut/" target="_blank">.fadeOut()</a></span>
</div><!-- .entry-meta -->
</header><!-- .entry-header -->
<!-- .entry-header -->
<div class="entry-content">
<article class="entry method" id="fadeOut1"><h2 class="section-title">
<span class="name">.fadeOut(  [duration ] [, complete ] )</span><span class="returns">返回: <a href="/Types/#jQuery">jQuery</a></span>
</h2>
<div class="entry-wrapper">
<p class="desc"><strong>描述: </strong>通过淡出的方式隐藏匹配元素。</p>
<ul class="signatures">
<li class="signature" id="fadeOut-duration-complete">
<h4 class="name">
<span class="version-details">添加的版本: <a href="/category/version/1.0/">1.0</a></span>.fadeOut( [duration ] [,
			            complete ] )</h4>
<ul>
<li>
<div>
<strong>duration</strong> (默认: <code>400</code>)
			                </div>
<div>类型: <a href="/Types/#Number">Number</a> or <a href="/Types/#String">String</a>
</div>
<div>一个字符串或者数字决定动画将运行多久。</div>
</li>
<li>
<div><strong>complete</strong></div>
<div>类型: <a href="/Types/#Function">Function</a>()</div>
<div>在动画完成时执行的函数。</div>
</li>
</ul>
</li>
<li class="signature" id="fadeOut-options">
<h4 class="name">
<span class="version-details">添加的版本: <a href="/category/version/1.0/">1.0</a></span>.fadeOut( options )</h4>
<ul>
<li>
<div><strong>options</strong></div>
<div>类型: <a href="/Types/#PlainObject">PlainObject</a>
</div>
<div>一组包含动画选项的值的集合。 支持的选项:</div>
<ul>
<li>
<div>
<strong>duration</strong> (default: <code>400</code>)
			                                    </div>
<div>Type: <a href="http://api.jquery.com/Types/#Number">Number</a> or <a href="http://api.jquery.com/Types/#String">String</a>
</div>
<div>一个字符串或者数字决定动画将运行多久。（注：默认值: "normal"， 三种预定速度的字符串("slow", "normal", 或
			                                        "fast")或表示动画时长的毫秒数值(如：1000) ）
			                                    </div>
</li>
<li>
<div>
<strong>easing</strong> (default: <code>swing</code>)
			                                    </div>
<div>Type: <a href="http://api.jquery.com/Types/#String">String</a>
</div>
<div>一个字符串，表示过渡使用哪种缓动函数。（注：jQuery自身提供"linear" 和 "swing"，其他效果可以使用<a href="http://gsgd.co.uk/sandbox/jquery/easing/">jQuery Easing Plugin</a>插件）
			                                    </div>
</li>
<li>
<div>
<strong>queue</strong> (default: <code>true</code>)
			                                    </div>
<div>Type: <a href="http://api.jquery.com/Types/#Boolean">Boolean</a> or <a href="http://api.jquery.com/Types/#String">String</a>
</div>
<div>
			
			                                        一个布尔值，指示是否将动画放置在效果队列中。如果为false时，将立即开始动画。 <strong>从jQuery1.7开始</strong>，队列选项也可以接受一个字符串，在这种情况下，在动画被添加到由该字符串表示的队列中。当一个自定义的队列名称被使用，动画不会自动启动;你必须调用<code>.dequeue("queuename")</code>来启动它。
			
			                                    </div>
</li>
<li>
<div><strong>specialEasing</strong></div>
<div>Type: <a href="http://api.jquery.com/Types/#PlainObject">PlainObject</a>
</div>
<div>一组一个或多个通过相应的参数和相对简单函数定义的CSS属性 ( <a href="/category/version/1.4/">1.4</a> 新增)
			                                    </div>
</li>
<li>
<div><strong>step</strong></div>
<div>Type: <a href="http://api.jquery.com/Types/#Function">Function</a>( <a href="http://api.jquery.com/Types/#Number">Number</a> now, <a href="http://api.jquery.com/Types/#Tween">Tween</a> tween )
			                                    </div>
<div>
			                                        每个动画元素的每个动画属性将调用的函数。这个函数为修改Tween 对象提供了一个机会来改变设置中得属性值。
			                                    </div>
</li>
<li>
<div><strong>progress</strong></div>
<div>Type: <a href="http://api.jquery.com/Types/#Function">Function</a>( <a href="http://api.jquery.com/Types/#Promise">Promise</a> animation, <a href="http://api.jquery.com/Types/#Number">Number</a> progress, <a href="http://api.jquery.com/Types/#Number">Number</a> remainingMs )
			                                    </div>
<div>
			                                        每一步动画完成后调用的一个函数，无论动画属性有多少，每个动画元素都执行单独的函数。<span class="version-details"> (version added: <a href="/category/version/1.8/">1.8</a>)</span>
</div>
</li>
<li>
<div><strong>complete</strong></div>
<div>Type: <a href="http://api.jquery.com/Types/#Function">Function</a>()</div>
<div>在动画完成时执行的函数。</div>
</li>
<li>
<div><strong>done</strong></div>
<div>Type: <a href="http://api.jquery.com/Types/#Function">Function</a>( <a href="http://api.jquery.com/Types/#Promise">Promise</a> animation, <a href="http://api.jquery.com/Types/#Boolean">Boolean</a> jumpedToEnd )
			                                    </div>
<div>在动画完成时执行的函数。 (他的Promise对象状态已完成).<span class="version-details"> (version added: <a href="/category/version/1.8/">1.8</a>)</span>
</div>
</li>
<li>
<div><strong>fail</strong></div>
<div>Type: <a href="http://api.jquery.com/Types/#Function">Function</a>( <a href="http://api.jquery.com/Types/#Promise">Promise</a> animation, <a href="http://api.jquery.com/Types/#Boolean">Boolean</a> jumpedToEnd )
			                                    </div>
<div>
			                                        动画失败完成时执行的函数。(他的Promise对象状态未完成)。<span class="version-details"> (version added: <a href="/category/version/1.8/">1.8</a>)</span>
</div>
</li>
<li>
<div><strong>always</strong></div>
<div>Type: <a href="http://api.jquery.com/Types/#Function">Function</a>( <a href="http://api.jquery.com/Types/#Promise">Promise</a> animation, <a href="http://api.jquery.com/Types/#Boolean">Boolean</a> jumpedToEnd )
			                                    </div>
<div>
			                                        在动画完成或未完成情况下停止时执行的函数。(他的Promise对象状态已完成或未完成)。<span class="version-details"> (version added: <a href="/category/version/1.8/">1.8</a>)</span>
</div>
</li>
</ul>
</li>
</ul>
</li>
<li class="signature" id="fadeOut-duration-easing-complete">
<h4 class="name">
<span class="version-details">添加的版本: <a href="/category/version/1.4.3/">1.4.3</a></span>.fadeOut( [duration
			            ] [, easing ] [, complete ] )</h4>
<ul>
<li>
<div>
<strong>duration</strong> (默认: <code>400</code>)
			                </div>
<div>类型: <a href="/Types/#Number">Number</a> or <a href="/Types/#String">String</a>
</div>
<div>一个字符串或者数字决定动画将运行多久。</div>
</li>
<li>
<div>
<strong>easing</strong> (默认: <code>swing</code>)
			                </div>
<div>类型: <a href="/Types/#String">String</a>
</div>
<div>一个字符串，表示过渡使用哪种缓动函数。（译者注：jQuery自身提供"linear" 和 "swing"，其他可以使用相关的插件）</div>
</li>
<li>
<div><strong>complete</strong></div>
<div>类型: <a href="/Types/#Function">Function</a>()</div>
<div>在动画完成时执行的函数。</div>
</li>
</ul>
</li>
</ul>
<div class="longdesc" id="entry-longdesc">
<p><code>.fadeOut()</code> 方法通过匹配元素的透明度执行动画效果。一旦透明度达到0，<code>display</code>样式属性将被设置为<code>none</code>，以确保该元素不再影响页面布局。</p>
<p>持续时间是以毫秒为单位的，数值越大，动画越慢，不是越快。字符串 <code>'fast'</code> 和 <code>'slow'</code> 分别代表200和600毫秒的延时。如果提供任何其他字符串，或者这个<code>duration</code>参数被省略，那么默认使用<code>400</code>毫秒的延时。</p>
<p>我们可以给任何元素做动画，比如一个简单的图片：</p>
<div class="syntaxhighlighter xml nogutter">
<table>
<tbody>
<tr>
<td class="gutter">
<div class="line n1">1</div>
<div class="line n2">2</div>
<div class="line n3">3</div>
<div class="line n4">4</div>
</td>
<td class="code">
<pre><div class="container"><div class="line"><code><span class="tag">&lt;<span class="title">div</span> <span class="attribute">id</span>=<span class="value">"clickme"</span>&gt;</span></code></div></div><div class="container"><div class="line"><code>  Click here</code></div></div><div class="container"><div class="line"><code><span class="tag">&lt;/<span class="title">div</span>&gt;</span></code></div></div><div class="container"><div class="line"><code><span class="tag">&lt;<span class="title">img</span> <span class="attribute">id</span>=<span class="value">"book"</span> <span class="attribute">src</span>=<span class="value">"book.png"</span> <span class="attribute">alt</span>=<span class="value">""</span> <span class="attribute">width</span>=<span class="value">"100"</span> <span class="attribute">height</span>=<span class="value">"123"</span> /&gt;</span></code></div></div></pre>
</td>
</tr>
</tbody>
</table>
</div>
<p>该元素开始是显示的，我们可以将其缓缓的隐藏：:</p>
<div class="syntaxhighlighter javascript nogutter">
<table>
<tbody>
<tr>
<td class="gutter">
<div class="line n1">1</div>
<div class="line n2">2</div>
<div class="line n3">3</div>
<div class="line n4">4</div>
<div class="line n5">5</div>
</td>
<td class="code">
<pre><div class="container"><div class="line"><code>$(<span class="string">'#clickme'</span>).click(<span class="keyword">function</span>() {</code></div></div><div class="container"><div class="line"><code>  $(<span class="string">'#book'</span>).fadeOut(<span class="string">'slow'</span>, <span class="keyword">function</span>() {</code></div></div><div class="container"><div class="line"><code>    <span class="comment">// Animation complete.</span></code></div></div><div class="container"><div class="line"><code>  });</code></div></div><div class="container"><div class="line"><code>});</code></div></div></pre>
</td>
</tr>
</tbody>
</table>
</div>
<p class="image four-across">
<img alt="" src="/resources/0042_06_37.png"/>
<img alt="" src="/resources/0042_06_38.png"/>
<img alt="" src="/resources/0042_06_39.png"/>
<img alt="" src="/resources/0042_06_40.png"/>
</p>
<blockquote>
<p><strong>注意: </strong>
			        为了避免不必要的DOM操作，<code>.fadeOut()</code> 不会隐藏已经被认为是隐藏的元素。有关jQuery的认为隐藏的元素，请参阅：<a href="/hidden-selector"> :hidden 选择器</a>。</p>
</blockquote>
<h4 id="easing">Easing</h4>
<p><strong>从jQuery 1.4.3开始</strong>,增加了一个字符串命名的可选的参数，用于确定使用的缓动函数。一个缓动函数指定用于动画进行中在不同点位的速度。 在jQuery库中easing默认的是调用 <code>swing</code>；如果想要在一个恒定的速度进行动画，那么调用 <code>linear</code>. 更多的缓动函数要使用的插件，最显着的是<a href="http://jqueryui.com/">jQuery UI suite</a>（译者注：或<a href="http://gsgd.co.uk/sandbox/jquery/easing/">jQuery Easing Plugin</a>插件）。</p>
<h4 id="callback-function">Callback Function（回调函数）</h4>
<p>如果提供回调函数，这个 <code>callback</code> 函数将在动画完成后被执行一次。这个能用来将不同的动画串联起来组成一个事件序列。这个回调函数不设置任何参数，但是<code>this</code>指向执行动画的DOM元素。如果多个元素一起做动画效果，值得注意的是这个回调函数在每个匹配元素上执行一次。这个动画不是作为一个整体。
			    </p>
<p>
<strong>从jQuery 1.6开始</strong>，<code><a href="/promise">.promise()</a></code>方法可以用来配合<code><a href="/deferred.done">deferred.done()</a></code> 方法作为一个整体，当所有匹配的元素已经完成各自的动画后，再执行一个回调的动画。 ( 查看 <a href="/promise">.promise() 例子</a> )。</p>
</div>
<h3>Additional Notes:(其他注意事项：)</h3>
<div class="longdesc"><ul><li>
			  所有jQuery效果，包括<code>.fadeOut()</code>,都能通过设置<code>jQuery.fx.off = true</code>全局的关闭，效果等同于持续时间设置为0。更多信息查看 <a href="/jquery.fx.off">jQuery.fx.off</a>.
			    </li></ul></div>
<section class="entry-examples" id="entry-examples"><header><h2 class="underline">例子:</h2></header><div class="entry-example" id="example-0">
<h4>Example: <span class="desc">让所有段落渐渐消失，用时 600 毫秒。</span>
</h4>
<div class="syntaxhighlighter xml ">
<table>
<tbody>
<tr>
<td class="gutter">
<div class="line n1">1</div>
<div class="line n2">2</div>
<div class="line n3">3</div>
<div class="line n4">4</div>
<div class="line n5">5</div>
<div class="line n6">6</div>
<div class="line n7">7</div>
<div class="line n8">8</div>
<div class="line n9">9</div>
<div class="line n10">10</div>
<div class="line n11">11</div>
<div class="line n12">12</div>
<div class="line n13">13</div>
<div class="line n14">14</div>
<div class="line n15">15</div>
<div class="line n16">16</div>
<div class="line n17">17</div>
<div class="line n18">18</div>
<div class="line n19">19</div>
<div class="line n20">20</div>
<div class="line n21">21</div>
</td>
<td class="code">
<pre><div class="container"><div class="line"><code><span class="doctype">&lt;!DOCTYPE html&gt;</span></code></div></div><div class="container"><div class="line"><code><span class="tag">&lt;<span class="title">html</span>&gt;</span></code></div></div><div class="container"><div class="line"><code><span class="tag">&lt;<span class="title">head</span>&gt;</span></code></div></div><div class="container"><div class="line"><code>  <span class="tag">&lt;<span class="title">style</span>&gt;</span><span class="css"></span></code></div></div><div class="container"><div class="line"><code>  <span class="tag">p</span> <span class="rules">{ <span class="rule"><span class="attribute">font-size</span>:<span class="value"><span class="number">150</span>%;</span></span> <span class="rule"><span class="attribute">cursor</span>:<span class="value">pointer;</span></span> <span class="rule">}</span></span></code></div></div><div class="container"><div class="line"><code>  <span class="tag">&lt;/<span class="title">style</span>&gt;</span></code></div></div><div class="container"><div class="line"><code>  <span class="tag">&lt;<span class="title">script</span> <span class="attribute">src</span>=<span class="value">"https://code.jquery.com/jquery-latest.js"</span>&gt;</span><span class="javascript"></span><span class="tag">&lt;/<span class="title">script</span>&gt;</span></code></div></div><div class="container"><div class="line"><code><span class="tag">&lt;/<span class="title">head</span>&gt;</span></code></div></div><div class="container"><div class="line"><code><span class="tag">&lt;<span class="title">body</span>&gt;</span></code></div></div><div class="container"><div class="line"><code>  <span class="tag">&lt;<span class="title">p</span>&gt;</span></code></div></div><div class="container"><div class="line"><code>  If you click on this paragraph</code></div></div><div class="container"><div class="line"><code>  you'll see it just fade away.</code></div></div><div class="container"><div class="line"><code>  <span class="tag">&lt;/<span class="title">p</span>&gt;</span></code></div></div><div class="container"><div class="line"><code><span class="tag">&lt;<span class="title">script</span>&gt;</span><span class="javascript"></span></code></div></div><div class="container"><div class="line"><code>  $(<span class="string">"p"</span>).click(<span class="function"><span class="keyword">function</span> <span class="params">()</span> {</span></code></div></div><div class="container"><div class="line"><code>  $(<span class="string">"p"</span>).fadeOut(<span class="string">"slow"</span>);</code></div></div><div class="container"><div class="line"><code>  });</code></div></div><div class="container"><div class="line"><code>  <span class="tag">&lt;/<span class="title">script</span>&gt;</span></code></div></div><div class="container"><div class="line"><code> </code></div></div><div class="container"><div class="line"><code><span class="tag">&lt;/<span class="title">body</span>&gt;</span></code></div></div><div class="container"><div class="line"><code><span class="tag">&lt;/<span class="title">html</span>&gt;</span></code></div></div></pre>
</td>
</tr>
</tbody>
</table>
</div>
<h4>Demo:</h4>
<div class="demo code-demo"></div>
</div>
<div class="entry-example" id="example-1">
<h4>Example: <span class="desc">将你点击的 span 淡出隐藏。</span>
</h4>
<div class="syntaxhighlighter xml ">
<table>
<tbody>
<tr>
<td class="gutter">
<div class="line n1">1</div>
<div class="line n2">2</div>
<div class="line n3">3</div>
<div class="line n4">4</div>
<div class="line n5">5</div>
<div class="line n6">6</div>
<div class="line n7">7</div>
<div class="line n8">8</div>
<div class="line n9">9</div>
<div class="line n10">10</div>
<div class="line n11">11</div>
<div class="line n12">12</div>
<div class="line n13">13</div>
<div class="line n14">14</div>
<div class="line n15">15</div>
<div class="line n16">16</div>
<div class="line n17">17</div>
<div class="line n18">18</div>
<div class="line n19">19</div>
<div class="line n20">20</div>
<div class="line n21">21</div>
<div class="line n22">22</div>
<div class="line n23">23</div>
<div class="line n24">24</div>
<div class="line n25">25</div>
<div class="line n26">26</div>
<div class="line n27">27</div>
<div class="line n28">28</div>
<div class="line n29">29</div>
<div class="line n30">30</div>
<div class="line n31">31</div>
<div class="line n32">32</div>
<div class="line n33">33</div>
<div class="line n34">34</div>
<div class="line n35">35</div>
<div class="line n36">36</div>
</td>
<td class="code">
<pre><div class="container"><div class="line"><code><span class="doctype">&lt;!DOCTYPE html&gt;</span></code></div></div><div class="container"><div class="line"><code><span class="tag">&lt;<span class="title">html</span>&gt;</span></code></div></div><div class="container"><div class="line"><code><span class="tag">&lt;<span class="title">head</span>&gt;</span></code></div></div><div class="container"><div class="line"><code>  <span class="tag">&lt;<span class="title">style</span>&gt;</span><span class="css"></span></code></div></div><div class="container"><div class="line"><code>  <span class="tag">span</span> <span class="rules">{ <span class="rule"><span class="attribute">cursor</span>:<span class="value">pointer;</span></span> <span class="rule">}</span></span></code></div></div><div class="container"><div class="line"><code>  <span class="tag">span</span><span class="class">.hilite</span> <span class="rules">{ <span class="rule"><span class="attribute">background</span>:<span class="value">yellow;</span></span> <span class="rule">}</span></span></code></div></div><div class="container"><div class="line"><code>  <span class="tag">div</span> <span class="rules">{ <span class="rule"><span class="attribute">display</span>:<span class="value">inline;</span></span> <span class="rule"><span class="attribute">color</span>:<span class="value">red;</span></span> <span class="rule">}</span></span></code></div></div><div class="container"><div class="line"><code>  <span class="tag">&lt;/<span class="title">style</span>&gt;</span></code></div></div><div class="container"><div class="line"><code>  <span class="tag">&lt;<span class="title">script</span> <span class="attribute">src</span>=<span class="value">"https://code.jquery.com/jquery-latest.js"</span>&gt;</span><span class="javascript"></span><span class="tag">&lt;/<span class="title">script</span>&gt;</span></code></div></div><div class="container"><div class="line"><code><span class="tag">&lt;/<span class="title">head</span>&gt;</span></code></div></div><div class="container"><div class="line"><code><span class="tag">&lt;<span class="title">body</span>&gt;</span></code></div></div><div class="container"><div class="line"><code>  <span class="tag">&lt;<span class="title">h3</span>&gt;</span>Find the modifiers - <span class="tag">&lt;<span class="title">div</span>&gt;</span><span class="tag">&lt;/<span class="title">div</span>&gt;</span><span class="tag">&lt;/<span class="title">h3</span>&gt;</span></code></div></div><div class="container"><div class="line"><code>  <span class="tag">&lt;<span class="title">p</span>&gt;</span></code></div></div><div class="container"><div class="line"><code>  If you <span class="tag">&lt;<span class="title">span</span>&gt;</span>really<span class="tag">&lt;/<span class="title">span</span>&gt;</span> want to go outside</code></div></div><div class="container"><div class="line"><code>  <span class="tag">&lt;<span class="title">span</span>&gt;</span>in the cold<span class="tag">&lt;/<span class="title">span</span>&gt;</span> then make sure to wear</code></div></div><div class="container"><div class="line"><code>  your <span class="tag">&lt;<span class="title">span</span>&gt;</span>warm<span class="tag">&lt;/<span class="title">span</span>&gt;</span> jacket given to you by</code></div></div><div class="container"><div class="line"><code>  your <span class="tag">&lt;<span class="title">span</span>&gt;</span>favorite<span class="tag">&lt;/<span class="title">span</span>&gt;</span> teacher.</code></div></div><div class="container"><div class="line"><code>  <span class="tag">&lt;/<span class="title">p</span>&gt;</span></code></div></div><div class="container"><div class="line"><code><span class="tag">&lt;<span class="title">script</span>&gt;</span><span class="javascript"></span></code></div></div><div class="container"><div class="line"><code> </code></div></div><div class="container"><div class="line"><code>  $(<span class="string">"span"</span>).click(<span class="function"><span class="keyword">function</span> <span class="params">()</span> {</span></code></div></div><div class="container"><div class="line"><code>  $(<span class="keyword">this</span>).fadeOut(<span class="number">1000</span>, <span class="function"><span class="keyword">function</span> <span class="params">()</span> {</span></code></div></div><div class="container"><div class="line"><code>  $(<span class="string">"div"</span>).text(<span class="string">"'"</span> + $(<span class="keyword">this</span>).text() + <span class="string">"' has faded!"</span>);</code></div></div><div class="container"><div class="line"><code>  $(<span class="keyword">this</span>).remove();</code></div></div><div class="container"><div class="line"><code>  });</code></div></div><div class="container"><div class="line"><code>  });</code></div></div><div class="container"><div class="line"><code>  $(<span class="string">"span"</span>).hover(<span class="function"><span class="keyword">function</span> <span class="params">()</span> {</span></code></div></div><div class="container"><div class="line"><code>  $(<span class="keyword">this</span>).addClass(<span class="string">"hilite"</span>);</code></div></div><div class="container"><div class="line"><code>  }, <span class="function"><span class="keyword">function</span> <span class="params">()</span> {</span></code></div></div><div class="container"><div class="line"><code>  $(<span class="keyword">this</span>).removeClass(<span class="string">"hilite"</span>);</code></div></div><div class="container"><div class="line"><code>  });</code></div></div><div class="container"><div class="line"><code> </code></div></div><div class="container"><div class="line"><code>  <span class="tag">&lt;/<span class="title">script</span>&gt;</span></code></div></div><div class="container"><div class="line"><code> </code></div></div><div class="container"><div class="line"><code><span class="tag">&lt;/<span class="title">body</span>&gt;</span></code></div></div><div class="container"><div class="line"><code><span class="tag">&lt;/<span class="title">html</span>&gt;</span></code></div></div></pre>
</td>
</tr>
</tbody>
</table>
</div>
<h4>Demo:</h4>
<div class="demo code-demo"></div>
</div>
<div class="entry-example" id="example-2">
<h4>Example: <span class="desc">将两个 div 淡出隐藏。其中一个使用 "linear" 缓冲效果，另一个使用默认的 "swing," 缓冲效果。</span>
</h4>
<div class="syntaxhighlighter xml ">
<table>
<tbody>
<tr>
<td class="gutter">
<div class="line n1">1</div>
<div class="line n2">2</div>
<div class="line n3">3</div>
<div class="line n4">4</div>
<div class="line n5">5</div>
<div class="line n6">6</div>
<div class="line n7">7</div>
<div class="line n8">8</div>
<div class="line n9">9</div>
<div class="line n10">10</div>
<div class="line n11">11</div>
<div class="line n12">12</div>
<div class="line n13">13</div>
<div class="line n14">14</div>
<div class="line n15">15</div>
<div class="line n16">16</div>
<div class="line n17">17</div>
<div class="line n18">18</div>
<div class="line n19">19</div>
<div class="line n20">20</div>
<div class="line n21">21</div>
<div class="line n22">22</div>
<div class="line n23">23</div>
<div class="line n24">24</div>
<div class="line n25">25</div>
<div class="line n26">26</div>
<div class="line n27">27</div>
<div class="line n28">28</div>
<div class="line n29">29</div>
<div class="line n30">30</div>
<div class="line n31">31</div>
<div class="line n32">32</div>
<div class="line n33">33</div>
<div class="line n34">34</div>
<div class="line n35">35</div>
<div class="line n36">36</div>
<div class="line n37">37</div>
<div class="line n38">38</div>
<div class="line n39">39</div>
<div class="line n40">40</div>
<div class="line n41">41</div>
</td>
<td class="code">
<pre><div class="container"><div class="line"><code><span class="doctype">&lt;!DOCTYPE html&gt;</span></code></div></div><div class="container"><div class="line"><code><span class="tag">&lt;<span class="title">html</span>&gt;</span></code></div></div><div class="container"><div class="line"><code><span class="tag">&lt;<span class="title">head</span>&gt;</span></code></div></div><div class="container"><div class="line"><code>  <span class="tag">&lt;<span class="title">style</span>&gt;</span><span class="css"></span></code></div></div><div class="container"><div class="line"><code><span class="class">.box</span>,</code></div></div><div class="container"><div class="line"><code><span class="tag">button</span> <span class="rules">{ <span class="rule"><span class="attribute">float</span>:<span class="value">left;</span></span> <span class="rule"><span class="attribute">margin</span>:<span class="value"><span class="number">5</span>px <span class="number">10</span>px <span class="number">5</span>px <span class="number">0</span>;</span></span> <span class="rule">}</span></span></code></div></div><div class="container"><div class="line"><code><span class="class">.box</span> <span class="rules">{ <span class="rule"><span class="attribute">height</span>:<span class="value"><span class="number">80</span>px;</span></span> <span class="rule"><span class="attribute">width</span>:<span class="value"><span class="number">80</span>px;</span></span> <span class="rule"><span class="attribute">background</span>:<span class="value"><span class="hexcolor">#090</span>;</span></span> <span class="rule">}</span></span></code></div></div><div class="container"><div class="line"><code><span class="id">#log</span> <span class="rules">{ <span class="rule"><span class="attribute">clear</span>:<span class="value">left;</span></span> <span class="rule">}</span></span></code></div></div><div class="container"><div class="line"><code> </code></div></div><div class="container"><div class="line"><code><span class="tag">&lt;/<span class="title">style</span>&gt;</span></code></div></div><div class="container"><div class="line"><code>  <span class="tag">&lt;<span class="title">script</span> <span class="attribute">src</span>=<span class="value">"https://code.jquery.com/jquery-latest.js"</span>&gt;</span><span class="javascript"></span><span class="tag">&lt;/<span class="title">script</span>&gt;</span></code></div></div><div class="container"><div class="line"><code><span class="tag">&lt;/<span class="title">head</span>&gt;</span></code></div></div><div class="container"><div class="line"><code><span class="tag">&lt;<span class="title">body</span>&gt;</span></code></div></div><div class="container"><div class="line"><code> </code></div></div><div class="container"><div class="line"><code><span class="tag">&lt;<span class="title">button</span> <span class="attribute">id</span>=<span class="value">"btn1"</span>&gt;</span>fade out<span class="tag">&lt;/<span class="title">button</span>&gt;</span></code></div></div><div class="container"><div class="line"><code><span class="tag">&lt;<span class="title">button</span> <span class="attribute">id</span>=<span class="value">"btn2"</span>&gt;</span>show<span class="tag">&lt;/<span class="title">button</span>&gt;</span></code></div></div><div class="container"><div class="line"><code> </code></div></div><div class="container"><div class="line"><code><span class="tag">&lt;<span class="title">div</span> <span class="attribute">id</span>=<span class="value">"log"</span>&gt;</span><span class="tag">&lt;/<span class="title">div</span>&gt;</span></code></div></div><div class="container"><div class="line"><code> </code></div></div><div class="container"><div class="line"><code><span class="tag">&lt;<span class="title">div</span> <span class="attribute">id</span>=<span class="value">"box1"</span> <span class="attribute">class</span>=<span class="value">"box"</span>&gt;</span>linear<span class="tag">&lt;/<span class="title">div</span>&gt;</span></code></div></div><div class="container"><div class="line"><code><span class="tag">&lt;<span class="title">div</span> <span class="attribute">id</span>=<span class="value">"box2"</span> <span class="attribute">class</span>=<span class="value">"box"</span>&gt;</span>swing<span class="tag">&lt;/<span class="title">div</span>&gt;</span></code></div></div><div class="container"><div class="line"><code> </code></div></div><div class="container"><div class="line"><code><span class="tag">&lt;<span class="title">script</span>&gt;</span><span class="javascript"></span></code></div></div><div class="container"><div class="line"><code>$(<span class="string">"#btn1"</span>).click(<span class="keyword">function</span>() {</code></div></div><div class="container"><div class="line"><code>  <span class="function"><span class="keyword">function</span> <span class="title">complete</span><span class="params">()</span> {</span></code></div></div><div class="container"><div class="line"><code>    $(<span class="string">"&lt;div/&gt;"</span>).text(<span class="keyword">this</span>.id).appendTo(<span class="string">"#log"</span>);</code></div></div><div class="container"><div class="line"><code>  }</code></div></div><div class="container"><div class="line"><code> </code></div></div><div class="container"><div class="line"><code>  $(<span class="string">"#box1"</span>).fadeOut(<span class="number">1600</span>, <span class="string">"linear"</span>, complete);</code></div></div><div class="container"><div class="line"><code>  $(<span class="string">"#box2"</span>).fadeOut(<span class="number">1600</span>, complete);</code></div></div><div class="container"><div class="line"><code>});</code></div></div><div class="container"><div class="line"><code> </code></div></div><div class="container"><div class="line"><code>$(<span class="string">"#btn2"</span>).click(<span class="keyword">function</span>() {</code></div></div><div class="container"><div class="line"><code>  $(<span class="string">"div"</span>).show();</code></div></div><div class="container"><div class="line"><code>  $(<span class="string">"#log"</span>).empty();</code></div></div><div class="container"><div class="line"><code>});</code></div></div><div class="container"><div class="line"><code> </code></div></div><div class="container"><div class="line"><code><span class="tag">&lt;/<span class="title">script</span>&gt;</span></code></div></div><div class="container"><div class="line"><code> </code></div></div><div class="container"><div class="line"><code><span class="tag">&lt;/<span class="title">body</span>&gt;</span></code></div></div><div class="container"><div class="line"><code><span class="tag">&lt;/<span class="title">html</span>&gt;</span></code></div></div></pre>
</td>
</tr>
</tbody>
</table>
</div>
<h4>Demo:</h4>
<div class="demo code-demo"></div>
</div></section>
</div></article> </div>
</article>